package com.liip.platform.controller;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.liip.platform.common.ReturnT;
import com.liip.platform.entity.Position;
import com.liip.platform.service.PositionService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @description 职位信息
 * @author 罗林
 * @date 2020-03-25 16:23:16
 */
@Api(tags = { "职位信息操作接口" })
@RestController
@RequestMapping(value = "/SysPosition")
public class PositionController {
	@Resource
	private PositionService positionService;

	/**
	 * 新增
	 * 
	 * @author 罗林
	 * @date 2020/03/25
	 **/
	@ApiOperation(value = "新增职位信息", notes = "新增职位信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "职位id", required = false),
			@ApiImplicitParam(name = "name", value = "职位名称", required = true),
			@ApiImplicitParam(name = "branchId", value = "所属部门id", required = false),
			@ApiImplicitParam(name = "branchName", value = "所属部门名称", required = true),
			@ApiImplicitParam(name = "menuId", value = "菜单id集合", required = false),
			@ApiImplicitParam(name = "createdat", value = "创建时间", required = false),
			@ApiImplicitParam(name = "updatedat", value = "更新时间", required = false) })
	@RequestMapping("/insert")
	public ReturnT<String> insert(Position position) {
		return positionService.insert(position);
	}

	/**
	 * 刪除
	 * 
	 * @author 罗林
	 * @date 2020/03/25
	 **/
	@ApiOperation(value = "刪除职位信息", notes = "刪除职位信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "职位id", required = true) })
	@RequestMapping("/delete")
	public ReturnT<String> delete(int id) {
		return positionService.delete(id);
	}

	/**
	 * 更新
	 * 
	 * @author 罗林
	 * @date 2020/03/25
	 **/
	@ApiOperation(value = "更新职位信息", notes = "更新职位信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "职位id", required = true),
			@ApiImplicitParam(name = "name", value = "职位名称", required = false),
			@ApiImplicitParam(name = "branchId", value = "所属部门id", required = false),
			@ApiImplicitParam(name = "branchName", value = "所属部门名称", required = false),
			@ApiImplicitParam(name = "menuId", value = "菜单id集合", required = false),
			@ApiImplicitParam(name = "createdat", value = "创建时间", required = false),
			@ApiImplicitParam(name = "updatedat", value = "更新时间", required = false) })
	@RequestMapping("/update")
	public ReturnT<String> update(Position position) {
		return positionService.update(position);
	}

	/**
	 * 查询 根据主键 id 查询
	 * 
	 * @author 罗林
	 * @date 2020/03/25
	 **/
	@ApiOperation(value = "根据主键 id 查询职位信息", notes = "根据主键 id 查询职位信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "职位id", required = true) })
	@RequestMapping("/load")
	public Position load(int id) {
		return positionService.load(id);
	}

	/**
	 * 查询 分页查询
	 * 
	 * @author 罗林
	 * @date 2020/03/25
	 **/
	@ApiOperation(value = "分页查询 职位信息", notes = "分页查询 职位信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "offset", value = "页码", required = true),
			@ApiImplicitParam(name = "pagesize", value = "数量", required = true) })
	@RequestMapping("/pageList")
	public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int offset,
			@RequestParam(required = false, defaultValue = "10") int pagesize) {
		return positionService.pageList(offset, pagesize);
	}

	// ===========================================分隔符======================================//
}
